<?php 
require 'global.php';
$keywords=$_GET['keywords'];
//$keywords=php;
if(!$keywords){
	echo "请输入关键字";
	exit;
}
$state=$_GET['state']?$_GET['state']:0;
$pn=$_GET['pn']?$_GET['pn']:1;
//$mc->flush();exit;
$sf=new searchFactory($db,$mc,$keywords,$search_urls);
$sf->set_page(PAGE);
$sf->set_returnCount(10);
if(1==$state){
	$kid=$sf->get_kid();	
	$star=$sf->get_star($kid);
	$results=$sf->save_result($kid,$star);	

$results2=$sf->start($star,$pn+1);
if(!empty($results2)){
?>
<span class="screw" rel="getMore.php?keywords=<?php echo $keywords;?>&pn=<?php echo $pn + 1;?>"></span>
<?php

}else{
	
	echo "对不起，没有搜索到更多相关结果！";
	
	
}
exit ;
}else{
$kid=$sf->get_kid();
$star=$sf->get_star($kid);
$results=$sf->start($star,$pn);

}
if(!empty($results)){
foreach($results as $key=>$p){
?>
<table cellpadding="0" cellspacing="0" class="result" id="table<?php echo $p -> rid;?>">
	<tbody>
		<tr>
			<td class="f">
				<h3 class="t"><a  href="<? echo $p -> url;?>" target="_blank"> <?php echo str_replace($keywords, '<em>' . $keywords . '</em>', $p -> title);?></a>
					<a  href="<? echo $p -> url;?>" target="_blank">下载</a></h3>
					<font><?php echo str_replace($keywords, '<em>' . $keywords . '</em>', $p -> remarks);?><br> 
						<span id='size<?php echo $p -> rid;?>'  class="size"></span> 
					</font></td>
		</tr>
	</tbody>
</table>
<script type="text/javascript">var size = '#size<?php echo $p -> rid;?>
    ';
    $(function() {
    load('<?php echo $p -> rid;?>','<? echo $p -> url;?>','<?php echo $p -> kid;?>');
    });
</script>
<?php
}
$results1=$sf->start($star,$pn+1);
if(!empty($results1)){
?>
<span class="screw" rel="getMore.php?keywords=<?php echo $keywords;?>&pn=<?php echo $pn + 1;?>"></span>
<?php }else{
echo "对不起，没有搜索到更多相关结果！";
?>
<script>
    $(function() {
        $('span[class=screw]').remove();
    })
</script>
<?php
}

}else{

echo "对不起，没有搜索到相关结果！";

}
?>

